import { request, uploadRequest } from '@/service/request/request';
import moduleStore from '@/store/module';

/**
 * 获取股票预测数据
 * @param {*} name 股票名
 */
export const getStockPrediction = async () => {
    try {
        const source = {
            time_step: 30
        };
		const res = await request('/user/file/stock-predict', source);
        moduleStore.setStockData(res);
    } catch (err) {
        throw err;
    }
};

/**
 * 获取天气预测数据
 */
export const getWeatherPrediction = async () => {
    try {
        const res = await request('/user/file/static_weather-predict', { time_step: 30 });
        moduleStore.setWeatherData(res);
    } catch (err) {
        throw err;
    }
};

/**
 * 获取电力预测数据
 */
export const getElectricityPrediction = async () => {
    try {
        const res = await request('/user/file/electricity-predict', { time_step: 30 });
        moduleStore.setElectricityData(res);
    } catch (err) {
        throw err;
    }
};

export const customPredict = async (data, filePath) => {
    try {
        return await uploadRequest('/user/file/submit-weather-predict', 'file', data, filePath);
    } catch (err) {
        throw err;
    }
};
